package com.jason.quectel.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * @author：Jason
 * @date：2022/3/10 11:33
 * @email：1129847330@qq.com
 * @description:
 */
public class SPUtils {
    private static final String SP_NAME = "quectel";
    private static SharedPreferences sharedPreferences;

    public static void init(Context context) {
        if (sharedPreferences == null) {
            sharedPreferences = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
        }
    }

    public static void put(String key, String value) {
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(key, value);
        editor.commit();
    }

    public static String get(String key, String defaultValue) {
        return sharedPreferences.getString(key, defaultValue);
    }
}